package cn.kgc.microservicecloudconsumerdept80.service;

import cn.kgc.microservicecloudapi.pojo.BookCategory;
import cn.kgc.microservicecloudapi.pojo.ResultEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CategoryClientServiceFallbackfactory  implements FallbackFactory<CategoryClientService> {
    @Override
    public CategoryClientService create(Throwable throwable) {
        return new CategoryClientService() {
            @Override
            public ResultEntity<List<BookCategory>> list() {
                return null;
            }

            @Override
            public ResultEntity<BookCategory> get(Integer id) {
                BookCategory category =new BookCategory();
                category.setId(id);
                category.setName("没有数据");
                return ResultEntity.failed(category,"没有数据");
            }

            @Override
            public ResultEntity<String> update(BookCategory category) {
                return null;
            }

            @Override
            public ResultEntity<String> insert(BookCategory category) {
                return null;
            }

            @Override
            public ResultEntity<String> delete(Integer id) {
                return null;
            }
        };
    }
}
